package main.aquarium

import kotlin.math.PI
import kotlin.math.roundToInt

open class Aquarium(var width: Int = 20, var height: Int = 40, var length: Int = 100) {
    open var volume: Int
        get() = width * height * length / 1000
        set(value) {
            height = value * 1000 / (width * length)
        }

    open var water = volume * 0.9

    constructor(numberOfFish: Int) : this() {
        val water = numberOfFish * 2000
        val tank = water + water * 0.1
        height = (tank / (length * width)).toInt()
    }
//    fun volume(): Int = width * height * length / 1000
}

class TowerTank : Aquarium() {
    override var water: Double = volume * 0.8
    override var volume: Int
        get() = ((width * height * length) / (1000 * PI)).roundToInt()
        set(value) {
            height = (value * 1000) / (width * length)
        }
}